<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.min.js"></script>
    <script src="../../js/env.js"></script>
    <title>充值</title>
</head>
<body>

<form class="layui-form" action="" style="text-align: center; margin: 100px">
    <br>
    <input hidden id="id">
    <div class="layui-form-item">
        <label class="layui-form-label">卡号</label>
        <div class="layui-input-block">
            <input type="text" id="cardNum" name="title" readonly lay-verify="title" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">充值金额</label>
        <div class="layui-input-block">
            <input type="text" id="money"  placeholder="请输入充值金额"  name="title" lay-verify="title" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> 备注信息</label>
        <div class="layui-input-block">
            <input type="text" id="remark" placeholder="请输入备注信息" name="title" lay-verify="title" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <button type="button" onclick="sub()" class="layui-btn layui-btn-fluid">确定</button>
</form>
</body>
<script>
    if (layui.sessionData('user').userInfo === undefined) {
        window.location.href = "../html/login.html"
    }
    layui.use(['form', 'layedit', 'laydate', 'upload'], function () {

    });
    //后台充值
    function sub() {
        var param = {};
        param.cardNum = $("#cardNum").val();
        param.agentUserId = layui.sessionData("user").userInfo.id;
        //校验金额
        var reg = /^[1-9]{1}[0-9]{0,10}[.]{0,1}[0-9]{0,2}$/;
        if(!reg.test($("#money").val())){
            layer.msg("金额只能是数字");
            return;
        }
        param.money = $("#money").val();
        param.remark = $("#remark").val();
        var url = getParam("url");
        var url1 = getParam("url1");
        param.id = $("#id").val();
        param.operation = 1;
        var response = MyAjax("POST", url, param, getToken());
        if(response.code===0){
            layer.msg("充值成功");
            setTimeout(function () {
                parent.layer.closeAll();
            },500)
            //表刷新方法
            var table = parent.layui.table;
            table.reload('testReload', {
                url:  abc() + url1
            });

        }
    }

</script>
</html>